package com.example.mybatisplus.web.controller;

import com.example.mybatisplus.mapper.AdminMapper;
//import jdk.internal.org.jline.terminal.impl.LineDisciplineTerminal;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.mybatisplus.common.JsonResponse;
import com.example.mybatisplus.service.AdminService;
import com.example.mybatisplus.model.domain.Admin;


/**
 *
 *  前端控制器
 *
 *
 * @author mmzm
 * @since 2021-06-17
 * @version v1.0
 */
@Controller
@RequestMapping("/api/admin")
public class AdminController {


//    get请求 用对想去去接


    @Autowired
    private AdminMapper adminMapper;

    @ResponseBody   //前后端的分离要用
    @RequestMapping("login")
    public JsonResponse login(Admin a)
    {

        Admin admin=adminMapper.selectByNameAndPwd(a.getLoginName(),a.getPassword());
        System.out.println(admin);
        return JsonResponse.success(admin);
    }
   @ResponseBody
    @PostMapping("testPost")
    public JsonResponse login1(@RequestBody Admin a)
   {
       Admin admin=adminMapper.selectByNameAndPwd(a.getLoginName(),a.getPassword());
       System.out.println(admin);
       return JsonResponse.success(admin);
   }
//   host
    @ResponseBody
    @RequestMapping("getCount")
    public JsonResponse getCount()
    {
       Integer integer= adminMapper.selectCount(null);
       return JsonResponse.success(integer);
    }

}

